package org.raymond.icloud.modules.admin.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.raymond.icloud.apis.admin.vo.InitEndVO;
import org.raymond.icloud.apis.admin.vo.InitStartVO;
import org.raymond.icloud.modules.admin.mapper.InitializeMapper;
import org.raymond.icloud.modules.admin.service.IInitializeService;
import org.raymond.icloud.modules.admin.service.ITSysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
@Service
public class InitializeServiceImpl implements IInitializeService {
    @Autowired
    private InitializeMapper initializeMapper;
    @Autowired
    private ITSysUserService itSysUserService;

    @Override
    public boolean dropAndCreateAllTable(InitStartVO inVO) {
        boolean result = false;
        try{
            initializeMapper.dropAndCreateAllTable();
            result = true;
        }catch (Exception e){
            log.error("dropAndCreateAllTable error: {}", e.getMessage());
        }
        return result;
    }

    @Override
    public boolean initConfiguration(InitStartVO inVO) {
        return false;
    }

    @Override
    public boolean initTestData(InitStartVO inVO) {
        itSysUserService.createRandomUser(inVO.getInitUserCount());
        return true;
    }

    @Override
    public boolean clear(InitEndVO inVO) {
        return false;
    }
}
